package cn.edu.tsinghua.ie.ieFunds.service;

import cn.edu.tsinghua.ie.ieFunds.bean.bussiness.Transaction;
import cn.edu.tsinghua.ie.ieFunds.bean.system.User;
import cn.edu.tsinghua.ie.ieFunds.repository.TransactionRepository;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class TransactionService {

    @Autowired
    private TransactionRepository transactionRepository;

    public void add(Transaction transaction) {
        transactionRepository.save(transaction);
    }

    public List<Transaction> getAllByUsername(User user) {
        return transactionRepository.findAllByUser(user);
    }
}
